import{g as p}from"./translation.js";import{d as g,e as n,o as v,aa as y,P as f,Q as h,$ as _,X as q,a4 as A,K as w,aE as F,N as T,R as b,a2 as E,a5 as M,G as P}from"./elementPlusModules.js";const k={style:{"margin-top":"10px",height:"30vh","background-color":"rgba(0, 0, 0, 0.3)"}},N=g({__name:"All",setup(D){const r=n(`
<template>
  <el-button type="primary" @click="init">刷新</el-button>
  <div v-loading="loading" style="margin-top: 10px; height: 30vh; background-color: rgba(0, 0, 0, 0.3)"></div>
</template>

<script setup lang="ts">
import { ref, onMounted } from "vue";

import { ElButton, ElMessage } from "element-plus";

import { getAllTranslationHeadApi } from "../../../../../api/modules/sysManage/translation";

const loading = ref(false);

// 获取页面数据
const queryData = async () => {
  // 真实接口案例
  const res = await getAllTranslationHeadApi({} as FormData);
  return res.data;
};
// 获取下拉选项
const queryOptions = () => {
  return new Promise(resolve => {
    setTimeout(() => {
      resolve({});
    }, 3000);
  });
};
// 获取筛选数据
const queryFilters = () => {
  return new Promise(resolve => {
    setTimeout(() => {
      resolve({});
    }, 500);
  });
};
// 初始化页面
const init = async () => {
  // 计时 start
  let t = 0;
  let timer: number = 0;
  const count = () => {
    t += 17;
    timer = requestAnimationFrame(count);
  };
  count();
  // 计时 end

  loading.value = true;
  await Promise.all([queryData(), queryOptions(), queryFilters()]).then(([data, options, filters]) => {
    // 获取三个接口返回数据
    // 消耗时间取接口返回最晚
    console.log(data);
  });
  loading.value = false;

  // 清除计时
  !!timer && cancelAnimationFrame(timer);
  ElMessage.success(\`多接口耗时\${t}毫秒\`);
};

onMounted(() => init());
<\/script>
`),s=n(!1),i=async()=>(await p({})).data,l=()=>new Promise(e=>{setTimeout(()=>{e({})},3e3)}),c=()=>new Promise(e=>{setTimeout(()=>{e({})},500)}),o=async()=>{let e=0,t=0;const a=()=>{e+=17,t=requestAnimationFrame(a)};a(),s.value=!0,await Promise.all([i(),l(),c()]).then(([u,m,d])=>{console.log(u,m,d)}),s.value=!1,t&&cancelAnimationFrame(t),P.success(`多接口耗时${e}毫秒`)};return v(()=>o()),(e,t)=>{const a=y("loading");return f(),h(M,null,[_(w(F),{type:"primary",onClick:o},{default:q(()=>[A("刷新")]),_:1}),T(b("div",k,null,512),[[a,s.value]]),E(e.$slots,"default",{html:r.value})],64)}}});export{N as _};
